<?php
/**
 * Created by PhpStorm.
 * User: laowang
 * Date: 2018/3/6
 * Time: 下午5:08
 */

namespace app\admin\controller;
use think\Db;

/**
 * Class Show
 * @package app\admin\controller
 * 组织架构
 */
class Show extends Admin
{
    public function index(){
        if (IS_POST){
            $data = input('post.');
            if ($data['id']){
                // 修改
                $res = Db::name('show')->where('id',$data['id'])->update(['content' => $data['content'],'create_time' => time()]);
            }else{
                // 添加
                $res = Db::name('show')->insert(['content' => $data['content'],'create_time' => time()]);
            }
            if ($res){
                return $this->success('操作成功');
            }else{
                return $this->error('操作失败');
            }
        }else{
            $info = Db::name('show')->find();
            $this->assign('msg',$info);
            return $this->fetch();
        }
    }
}